
const path = require('path')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
    entry: path.resolve(__dirname, './index.js'),
    output: {
        path: path.resolve(__dirname, './build/lib'),
        filename: 'main.js',
        libraryTarget:'umd',
    },
    module: {
        rules: [
            {
                test: /\.jsx$|.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        babelrc: false,
                        presets: [
                            require.resolve('@babel/preset-react') ,[require.resolve('@babel/preset-env'), { modules: false }]
                        ],
                        cacheDirectory: true
                    },
                }
            },
            {
                test: /\.js$|\.js$/,
                enforce: 'pre',
                use: ['source-map-loader'],
            },
            {
                test: /\.css$/,
                use: [{ loader: 'style-loader', options: {} }, 'css-loader'],
            }
        ]
    },
    optimization: {
        minimizer: [new UglifyJsPlugin({
            chunkFilter: (chunk) => {
                if (chunk.name === 'vendor') {
                    return false;
                }
                return true;
            },
            parallel: true
        })],
    },
    externals:{'react':"react"},
    ignoreWarnings: [/Failed to parse source map/]
}
